#/usr/bin/env python
"""
This simple example is used for the line-by-line tutorial
that comes with pygame. It is based on a 'popular' web banner.
Note there are comments here, but for the full explanation, 
follow along in the tutorial.
"""


#Import Modules
import os, pygame
from pygame.locals import *
from functions import *

class Poke(pygame.sprite.Sprite):
    """moves a poking finger on the screen, following the mouse"""
    def __init__(self):
        pygame.sprite.Sprite.__init__(self) #call Sprite initializer
        self.image, self.rect = load_image('poke.png', -1)
        self.poking = 0

    def update(self):
        "move the poke based on the mouse position"
        pos = pygame.mouse.get_pos()
        self.rect.midtop = pos
        if self.poking:
            self.rect.move_ip(5, 10)

    def poke(self, target):
        "returns true if the poke collides with the target"
        if not self.poking:
            self.poking = 1
            hitbox = self.rect.inflate(-5, -5)
            return hitbox.colliderect(target.rect)

    def unpoke(self):
        "called to pull the poke back"
        self.poking = 0

